﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public interface IDbTreeNode
{
    string dbType { get; set; }
    string connectionString { get; set; }
}

public interface ITreeNodeData
{
    string text { get; }
    string type { get; }
    string icon { get; }
}


/// <summary>
/// 表
/// </summary>
public class TreeTable : ITreeNodeData, IDbTreeNode
{ 
    public string dbType { get; set; }
    public string connectionString { get; set; }
    public string name { get; set; }
    public string text { get { return name; } }
    public string type { get { return "table"; } }
    public string icon { get { return "images/table.png"; } }
}

/// <summary>
/// 视图
/// </summary>
public class TreeView : ITreeNodeData, IDbTreeNode
{
    public string dbType { get; set; }
    public string connectionString { get; set; }
    public string name { get; set; }
    public string text { get { return name; } }
    public string type { get { return "view"; } }
    public  string icon { get { return "images/view.png"; } }
}

/// <summary>
/// 视图
/// </summary>
public class TreeColumn : ITreeNodeData, IDbTreeNode
{
    public bool isInPrimaryKey { get; set; }
    public bool isInForeignKey { get; set; }
    public string dbType { get; set; }
    public string connectionString { get; set; }
    public string name { get; set; }
    public string text { get { return name; } }
    public string type { get { return "column"; } }
    public string icon
    {
        get
        {
            return isInPrimaryKey ? "images/table_key.png" : "images/table_column.png";
        }
    }
}